local skel = fk.CreateSkill {
  name = "efengqi__chuli",
}

Fk:loadTranslationTable{
  ["efengqi__chuli"] = "除疠",
  [":efengqi__chuli"] = "出牌阶段限一次，你可以重铸一张♣牌，并弃置任意名角色共四张牌，然后令因此失去♠牌的角色摸牌至体力上限。",

  ["#efengqi__chuli"] = "除疠：重铸一张♣牌，弃置任意名角色共四张牌",
  ["#efengqi__chuli-choose"] = "除疠：选择一名角色，弃置其至多 %arg 张牌",

  ["$efengqi__chuli1"] = "病去，如抽丝。",
  ["$efengqi__chuli2"] = "病入膏肓，需下猛药。",
}

skel:addEffect("active", {
  anim_type = "control",
  card_num = 1,
  target_num = 0,
  prompt = "#efengqi__chuli",
  card_filter = function (self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).suit == Card.Club
  end,
  times = function (self, player)
    return 1 - player:usedSkillTimes(self.name, Player.HistoryPhase)
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:recastCard(effect.cards, player, self.name)
    if player.dead then return end
    local n, drawer = 4, {}
    -- 滕芳兰式弃牌，任意角色共计4张
    while n > 0 and player:isAlive() do
      local targets = table.filter(room.alive_players, function (p) return not p:isNude() end)
      if #targets == 0 then break end
      local tos = room:askToChoosePlayers(player, { targets = targets, min_num = 1, max_num = 1,
      prompt = "#efengqi__chuli-choose:::"..n, skill_name = self.name, cancelable = false})
      if #tos == 0 then break end
      local to = tos[1]
      local cards = room:askToChooseCards (player, { target = to, min = 1, max = n, flag = "he", skill_name = self.name})
      n = n - #cards
      if table.find(cards, function (id) return Fk:getCardById(id).suit == Card.Spade end) then
        table.insertIfNeed(drawer, to)
      end
      room:throwCard(cards, self.name, to, player)
    end
    if #drawer > 0 then
      room:delay(300)
      room:sortByAction(drawer)
      room:doIndicate(player, drawer)
      for _, p in ipairs(drawer) do
        if not p.dead then
          local num = p.maxHp - p:getHandcardNum()
          if num > 0 then
            p:drawCards(num, self.name)
          end
        end
      end
    end
  end,
})

return skel
